package com.lovo.test.LicensingSystem;

import com.lovo.test.text.Studends;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class DouDiZhu {
    private static ArrayList<Card> list = new ArrayList();
    private static List player1 = new ArrayList();
    private static List player2 = new ArrayList();
    private static List player3 = new ArrayList();
    private static List player4 = new ArrayList();

    public static ArrayList<Card> getList() {
        return list;
    }

    public static void setList(ArrayList<Card> list) {
        DouDiZhu.list = list;
    }

    public static List getPlayer1() {
        return player1;
    }

    public static void setPlayer1(List player1) {
        DouDiZhu.player1 = player1;
    }

    public static List getPlayer2() {
        return player2;
    }

    public static void setPlayer2(List player2) {
        DouDiZhu.player2 = player2;
    }

    public static List getPlayer3() {
        return player3;
    }

    public static void setPlayer3(List player3) {
        DouDiZhu.player3 = player3;
    }

    public static List getPlayer4() {
        return player4;
    }

    public static void setPlayer4(List player4) {
        DouDiZhu.player4 = player4;
    }

    public static void main(String[] args) {
        init();
        xipai();
        fapai();



    }
    //排序
    public static void sort(List list) {
        list.sort(new Comparator<Card>() {
            @Override
            public int compare(Card o1, Card o2) {
                if (o1.getPointValue() == o2.getPointValue()) {
                    return o1.getTypValue() - o2.getTypValue();
                } else {
                    return o1.getPointValue() - o2.getPointValue();
                }
            }
        });

    }


    // 发牌
    public static void fapai() {
        player1 =  list.subList(0, 17);
        player2 =  list.subList(17, 34);
        player3 = list.subList(34, 51);
        player4 =  list.subList(51, 54);
        sort(player1);
        sort(player2);
        sort(player3);
        sort(player4);
    }

    // 洗牌
    public static void xipai() {
        Collections.shuffle(list);
//        for (Object obj : list) {
//            System.out.println(obj);
//        }

    }

    // 初始化54张扑克牌
    public static void init() {
        String[] type = {"1", "2", "3", "4"};
        String[] number = { "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14","15"};

        list.add(new Card("16_1"+"","",13,0));
        list.add(new Card("17_1","",14,0));
        for (int i = 0; i < type.length; i++) {
            for (int j = 0; j < number.length; j++) {
                list.add(new Card(number[j]+"_",type[i],j,i));
            }
        }
        System.out.println(list.toString());

    }


}
